import request, { extend } from 'umi-request';
// import { extend } from 'umi-request';


const res = extend({
  prefix: "/api",
  timeout: 5000,
  headers: { Authorization: localStorage.token || '' },
});



//新增发票
export async function BillAdd(
  body?:API.BillInfo,
  ) {
  return res<API.Result>('/bill/addBill',
    {
      method: 'post',
      headers: {
        "Content-Type": "application/json"
      },
      data:body,
    })
}

export async function QueryBillList(
  body?:API.QueryBillListInfo,
  noError?: { [key: string]: any },//不一定用，处理
  ) {
  return res<API.Result>('/bill/queryBillList',
    {
      method: 'post',
      headers: {
        "Content-Type": "application/json"
      },
      data:body,
    })
}

export async function cancelBill(
  data?:string
  ) {
  return res<API.Result>(`/bill/cancelBill/${data}`,
    {
      method: 'put',
      headers: {
        "Content-Type": "application/json"
      },
      params:{billOrderPhone:data},
    })
}

export async function DelBill(
  data?:string
  ) {
  return res<API.Result>(`/bill/deleteBill/${data} `,
    {
      method: 'DELETE',
      headers: {
        "Content-Type": "application/json"
      },
      params:{billOrderPhone:data},
    })
}

export async function queryBillById(
  data?:string,
  ) {
  return res<API.Result>(`/bill/queryBillById/${data}`,
    {
      method: 'get',
      headers: {
        "Content-Type": "application/json"
      },
      data:{billOrderPhone:data},
    })
}

//抬头
export async function addCollectTickets(
  body?:API.CollectTicketsList,
  ) {
  return res<API.Result>('/collect-tickets/addCollectTickets',
    {
      method: 'post',
      headers: {
        "Content-Type": "application/json"
      },
      data:body,
    })
}

export async function getCollectTicketTure(
  data?:API.CollectTicketsList,
  ) {
  return res<API.Result>(`/collect-tickets/getCollectTicketTure/${data}`,
    {
      method: 'GET',
      headers: {
        "Content-Type": "application/json"
      },
      data:{userId:data},
    })
}

export async function QueryCollectTickets(
  body?:API.CollectTicketsList,
  ) {
  return res<API.Result>('/collect-tickets/getCollectTicketByUser',
    {
      method: 'post',
      headers: {
        "Content-Type": "application/json"
      },
      data:body,
    })
}

export async function upDataCollectTickets(
  body?:API.CollectTicketsList,
  ) {
    
  return res<API.Result>('/collect-tickets/upDataCollectTickets',
    {
      method: 'post',
      headers: {
        "Content-Type": "application/json"
      },
      data:body,
    })
}

export async function deleteCollectTicket(
  data?:string,
  ) {
  return res<API.Result>(`/collect-tickets/deleteCollectTicket/${data}`,
    {
      method: 'DELETE',
      headers: {
        "Content-Type": "application/json"
      },
      data:{id:data},
    })
}

export async function modifyTheDefault(
  data?:string,
  ) {
  return res<API.Result>(`/collect-tickets/modifyTheDefault/${data}`,
    {
      method: 'put',
      headers: {
        "Content-Type": "application/json"
      },
      data:{id:data},
    })
}